package com.glsc.ngateway.common.base.converter.platform;

import com.alibaba.excel.util.CollectionUtils;
import com.glsc.ngateway.common.api.flowable.dto.CmdbCpuStandardDto;
import com.glsc.ngateway.common.base.domain.mysql.cmdb.CmdbCpuStandard;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @author xuchang
 */
public class CmdbCpuStandardConverter {

    public static CmdbCpuStandardDto do2Dto(CmdbCpuStandard domain) {
        if (Objects.isNull(domain)) {
            return null;
        }
        return CmdbCpuStandardMapper.INSTANCE.do2Dto(domain);
    }

    public static List<CmdbCpuStandardDto> do2Dto(List<CmdbCpuStandard> domainList) {
        return CollectionUtils.isEmpty(domainList) ? java.util.Collections.emptyList() : domainList.stream().map(CmdbCpuStandardConverter::do2Dto).collect(Collectors.toList());
    }

    public static CmdbCpuStandard dto2Do(CmdbCpuStandardDto dto) {
        if (Objects.isNull(dto)) {
            return null;
        }
        return CmdbCpuStandardMapper.INSTANCE.dto2Do(dto);
    }

    public static List<CmdbCpuStandard> dto2Do(List<CmdbCpuStandardDto> dtoList) {
        return CollectionUtils.isEmpty(dtoList) ? java.util.Collections.emptyList() : dtoList.stream().map(CmdbCpuStandardConverter::dto2Do).collect(Collectors.toList());
    }

    @Mapper(componentModel = "spring")
    public interface CmdbCpuStandardMapper {

        CmdbCpuStandardMapper INSTANCE = Mappers.getMapper(CmdbCpuStandardMapper.class);

        CmdbCpuStandardDto do2Dto(CmdbCpuStandard domain);

        List<CmdbCpuStandardDto> do2Dto(List<CmdbCpuStandard> domain);

        CmdbCpuStandard dto2Do(CmdbCpuStandardDto dto);

        List<CmdbCpuStandard> dto2Do(List<CmdbCpuStandardDto> dto);
    }
}
